package com.jap.entity;

import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @Description
 * @Author 顾志杰
 * @Date 2022/9/12 10:20
 */
@Data
@Entity
//@SQLDelete(sql = "update component_info set deleted = " + Delete.DELETE + " where id = ?")默认删除语句
//@Where(clause = "deleted = " + Delete.NORMAL)查询添加统一条件
//@SQLRestriction(value = "del_flag = 0") jpa6.5以上@Where的替换
public class User {
  @Id
  @GeneratedValue(generator = "uuid2")
  @GenericGenerator(name = "uuid2", strategy = "org.hibernate.id.UUIDGenerator")
  private String id;

  @Column(name = "user_name")
  private String userName;

  private String passWord;

  private LocalDateTime createTime;

  private Integer age;

  @ManyToOne(fetch = FetchType.LAZY)//懒加载 ps：懒加载作用域需要在service加@Transactional事务注解 否则报NO session
  @JoinColumn(name = "details_id")
  private UserDetails userDetails;

  @ManyToMany(fetch = FetchType.LAZY)
  @JoinTable(name = "user_dept", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "dept_id"))
  private List<Dept> depts;



  //忽略字段
  @Transient
  private String transientStr;

}
